package com.atshiyou.service.impl;

import com.atshiyou.bean.Bills;
import com.atshiyou.dao.BillsMapper;
import com.atshiyou.service.BillsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class BillsServiceImpl implements BillsService{

    @Resource
    private BillsMapper dao;
    @Override
    public PageInfo<Bills> findAll(int typeid, String begin, String end, int page, int size) {
        Map param = new HashMap();
        param.put("tid",typeid);
        param.put("begin",begin);
        param.put("end",end);
        //1、指定分页数据
        PageHelper.startPage(page,size);
        //2、查询数据
        List<Bills> billsList = dao.findAll(param);
        //3、创建分页工具类
        PageInfo<Bills> pageInfo = new PageInfo<>(billsList);

        return pageInfo;
    }

    @Override
    public int insert(Bills record) {
        return dao.insert(record);
    }

    @Override
    public Bills selectByPrimaryKey(Integer id) {
        return dao.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKey(Bills record) {
        return dao.updateByPrimaryKeySelective(record);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return dao.deleteByPrimaryKey(id);
    }
}
